package com.zhuangjie.shop.vo.predetermine;

import com.zhuangjie.shop.vo.TimeItem;
import lombok.Data;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;

/**
 * 日期项目（时间选择左侧）
 *
 * @author zhuangjie
 * @date 2023/11/25
 */
@Data
public class DateItem {
    private String ymdLabel;
    private String ymdFormat; // yyyy-MM-dd
    private List<TimeItem> times;

    public DateItem() {
    }

    public DateItem(String ymdLabel, String ymdFormat, List<TimeItem> times) {
        this.ymdLabel = ymdLabel;
        this.ymdFormat = ymdFormat;
        this.times = times;
    }

    public boolean dateEquals(LocalDate localDateTime) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        return Objects.equals(localDateTime.format(formatter),this.ymdFormat);
    }
}
